package com.china.action;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;

import com.china.pageModel.LngLat;
import com.china.pageModel.User;
import com.china.service.LongLatServiceI;
import com.opensymphony.xwork2.ModelDriven;

/**
 * 继承ModelDriven时要指定前台请求的数据模型
 * 如果不跳转方法返回void即可(datagroid方法  : /longLatAction!datagrid.action)
 * 如果要跳转方法返回方法名称的字符串,并且在注解中声明要跳转的页面(userAdd方法: /longLatAction!userAdd.action)
 * @author Administrator
 *
 */
@Namespace("/")
@Action(
		value="longLatAction",
		results={
			@Result(name="user",location="/demo/user.jsp"),
			@Result(name="userAdd",location="/demo/userAdd.jsp"),
			@Result(name="userDelete",location="/demo/userDelete.jsp")
})
public class LongLatAction extends BaseAction implements ModelDriven<LngLat> {
	
	private LngLat lngLat = new LngLat();//要创建对象
	@Override
	public LngLat getModel() {
		// TODO Auto-generated method stub
		return lngLat;
	}
	
	private LongLatServiceI longLatService;
	
	@Autowired
	public void setLongLatService(LongLatServiceI longLatService) {
		this.longLatService = longLatService;
	}
	
	public LongLatServiceI getLongLatService() {
		return longLatService;
	}

	public void user(){
		
		lngLat.setCounty("中国鉴定费");
		super.writeJson(lngLat);
		//return "user";
	}
	
	public String userAdd(){
		return "userAdd";
	}
	
	public String userDelete(){
		return "userDelete";
	}
	
	public void datagrid(){
		
		super.writeJson(this.longLatService.datagrid(lngLat));
	}
}
